package com.aihome.springbootxxljob.jobhandler;

import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author zhangjigang
 * @description 测试job
 * @className TestJob
 * @date 2021/6/15 15:18
 * @vision 1.0.0
 */
@Component
@Slf4j
public class TestJob {

    @XxlJob(value = "testJob", init = "init", destroy = "destroy")
    public void testJob() {
        XxlJobHelper.log("测试任务testJob-start");
        log.info("测试任务testJob-start");
    }

    @XxlJob(value = "testJobParams")
    public void testJobParams() {
        String jobParam = XxlJobHelper.getJobParam();
        int count = Integer.parseInt(jobParam);
        XxlJobHelper.log("测试任务testJobParams-start");
        log.info("测试任务testJobParams-start");
        for (int i = 0; i < count; i++) {
            XxlJobHelper.log("输出值：{}", i);
            log.info("输出值：{}", i);
        }
    }

    public void init() {
        log.info("测试任务init");
    }

    public void destroy() {
        log.info("测试任务destroy");
    }
}
